package org.aplikator.server.descriptor;

import org.aplikator.client.descriptor.TextAreaDTO;
import org.aplikator.client.descriptor.WidgetDTO;
import org.aplikator.server.Context;

public class TextArea implements Widget, HasProperty<String> {

    private Property<String> property;

    private boolean labelAbove = true;

    private String width;
    private String height;

    public TextArea(Property<String> property) {
        this.property = property;
    }

    public Property<String> getProperty() {
        return property;
    }

    public WidgetDTO getWidgetDescriptor(Context ctx) {
        TextAreaDTO desc = new TextAreaDTO(property.clientClone(ctx));
        desc.setLabelAbove(labelAbove);
        desc.setWidth(width);
        desc.setHeight(height);
        return desc;
    }

    public void registerProperties(Form form) {
        form.addProperty(property);
    }

    public boolean isLabelAbove() {
        return labelAbove;
    }

    public TextArea setLabelAbove(boolean labelAbove) {
        this.labelAbove = labelAbove;
        return this;
    }

    public TextArea setWidth(String width) {
        this.width = width;
        return this;
    }

    public String getWidth() {
        return width;
    }

    public TextArea setHeight(String height) {
        this.height = height;
        return this;
    }

    public String getHeight() {
        return height;
    }
}
